package com.blacktea.behavioralpatterns.chainofresponsibilitypattern.handler;

import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

/**
 * @description: 打印请求参数
 * @author: black tea
 * @date: 2023/3/24 16:21
 */
@Slf4j
@Component
public class ParamLogger extends RequestLogger {

    @Override
    public void handler(HttpServletRequest request) {
        log.info("请求参数:{}", JSONUtil.toJsonStr(request.getParameterMap()));
        if (nextHandler != null){
            nextHandler.handler(request);
        }
    }

    @Override
    public int order() {
        return 101;
    }
}
